package com.example.onlinereadingsystem.demos.web.controller.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.onlinereadingsystem.demos.web.dto.domain.User;
import com.example.onlinereadingsystem.demos.web.dto.request.*;
import com.example.onlinereadingsystem.demos.web.dto.vo.MyCommentVo;
import com.example.onlinereadingsystem.demos.web.dto.vo.MyFansVo;
import com.example.onlinereadingsystem.demos.web.dto.vo.MyFollowersVo;
import com.example.onlinereadingsystem.demos.web.dto.vo.UserInfoVo;
import com.example.onlinereadingsystem.demos.web.service.UserService;
import com.example.onlinereadingsystem.demos.web.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description 个人中心页接口
 * @Author ljm
 * @Date 2024/10/9
 */
@RestController
@RequestMapping("/web/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * @auther ljm
     * @create 2024/10/18
     * @describe 根据用户id获取用户详情
     */
    @GetMapping("/getUserInfo/{id}")
    public Result<UserInfoVo> getUserInfoById(@PathVariable String id) {
        return userService.getUserInfoById(id);
    }

    /**
     * @auther ljm
     * @create 2024/12/26
     * @describe 修改用户信息
     */
    @PutMapping("/updateUserInfo")
    public Result<Boolean> updateUserInfo(@RequestBody UpdateUserInfoParam param) {
        return userService.updateUserInfo(param);
    }

    /**
     * @auther ljm
     * @create 2024/12/26
     * @describe 上传头像
     */
    @PostMapping("/uploadAvatar")
    public Result<String> uploadAvatar(MultipartFile file) {
        return userService.uploadAvatar(file);
    }

    /**
     * @auther ljm
     * @create 2024/12/26
     * @describe 获取我的评论
     */
    @GetMapping("/getMyComments")
    public Result<IPage<MyCommentVo>> getMyComments(MyCommentParam param) {
        return userService.getMyComments(param);
    }

    /**
     * @auther ljm
     * @create 2025/1/10
     * @describe 获取我的粉丝
     */
    @GetMapping("/getMyFans")
    public Result<IPage<MyFansVo>> getMyFans(MyFansParam param) {
        return userService.getMyFans(param);
    }

    /**
     * @auther ljm
     * @create 2025/1/10
     * @describe 获取我的关注
     */
    @GetMapping("/getMyFollowers")
    public Result<IPage<MyFollowersVo>> getMyFollowers(MyFollowersParam param) {
        return userService.getMyFollowers(param);
    }

    /**
     * @auther ljm
     * @create 2025/1/29
     * @describe 关注用户
     */
    @PostMapping("/followed")
    public Result<Boolean> followed(@RequestBody FollowedParam param) {
        return userService.followed(param);
    }

    /**
     * @auther ljm
     * @create 2025/1/29
     * @describe 取消关注用户
     */
    @PutMapping("/cancelFollow")
    public Result<Boolean> cancelFollow(@RequestBody CancelFollowParam param) {
        return userService.cancelFollow(param);
    }
}
